home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / qbasicpg.zip / ADDTHEM2.BAS < prev    next >
BASIC Source File  |  1989-08-31  |  656b  |  21 lines

  1. ' ADDTHEM2.BAS
  2. ' This program reads and adds values stored in DATA statements
  3. '   until an end-of-data marker (-9999) is detected.
  4.  
  5. CLS
  6.  
  7. DO WHILE (number! <> -9999)     ' loop until end-of-data marker read
  8.     READ number!                ' assign next DATA item to number!
  9.     IF (number! <> -9999) THEN  ' if not end-of-data marker then
  10.         sum! = sum! + number!   '   keep a running total
  11.         items% = items% + 1     '   count the number of values read
  12.     END IF
  13. LOOP
  14.  
  15. PRINT "The sum of the"; items%; "numbers is"; sum!
  16.  
  17. DATA 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
  18. DATA 88.2, 25, 3.3, 100, -74.2, 0, 20, 0.34, -89, 5.4567
  19. DATA -9999
  20.  
  21.